import { getAgentTableData, getStationList } from '@/api/data2'
export default {
  namespaced: true,
  state: {
    selections: [],
    allAgents: [],
    selectStations: [],
    allStations: []
  },
  mutations: {
    setSelections (state, selection) {
      state.selections = selection
    },
    setAllAgents (state, selections) {
      state.allAgents = selections
    },
    setStations (state, station) {
      state.selectStations = station
    },
    setAllStations (state, payload) {
      state.allStations = payload
    }
  },
  actions: {
    async getAgentList ({ commit }) {
      const { code, data, desc } = await getAgentTableData()
      if (code == 200) {
        const res = data.datalist || []
        commit('setAllAgents', res)
      }
      return { code, desc }
    },
    async getStationList ({ commit }, payload) {
      const { code, data, desc } = await getStationList(payload)
      if (code == 200) {
        const res = data.datalist || []
        commit('setAllStations', res)
      }
      return { code, desc }
    }

  }
}
